package edu.scau.divineplace.config.global.validate.annotation;

import javax.validation.Constraint;
import javax.validation.Payload;
import javax.validation.constraints.NotNull;
import java.lang.annotation.Documented;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.ElementType.TYPE_USE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;


import edu.scau.divineplace.config.global.validate.annotation.NotContainBanWord.List;
import edu.scau.divineplace.config.global.validate.validator.NotContainBanWordValidator;

/**
 * @Author: x1aolone
 * @Date: 2021/1/14 16:51
 * 判断评论是否有禁用词的注解
 */
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
@Retention(RUNTIME)
@Repeatable(List.class)
@Documented
@Constraint(validatedBy = {NotContainBanWordValidator.class})
public @interface NotContainBanWord {

    // 默认错误消息
    String message() default "发言存在违禁词";

    Class<?>[] groups() default { };

    Class<? extends Payload>[] payload() default { };

    /**
     * Defines several {@link NotContainBanWord} annotations on the same element.
     * 指定多个时使用
     */
    @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
    @Retention(RUNTIME)
    @Documented
    @interface List {
        NotContainBanWord[] value();
    }
}
